package net.qiqbframework.commandhandling;

import javax.annotation.Nonnull;

/**
 * 命令结果回调
 *
 * @param <C>
 * @param <R>
 */
@FunctionalInterface
public interface CommandCallback<C, R> {


    void onResult(@Nonnull CommandMessage<? extends C> commandMessage, @Nonnull CommandResultMessage<? extends R> commandResultMessage);

    default CommandCallback<C, R> wrap(CommandCallback<C, R> wrappingCallback) {
        if (wrappingCallback == null) {
            return this;
        }
        return new WrappedCommandCallback<>(wrappingCallback, this);
    }
}
